<?php
declare (strict_types = 1);
namespace app\admin\model;

use app\admin\model\Common;

class Classs extends Common
{
	/**
	 * 分类
	 */
	public function classs()
	{
		return $this->belongsTo(Classs::class);
	}

	/**
	 * 获取列表
	 */
	public function level(){
		$info = $this
			//->where(['status'=>1])
			->select();
		return $info->toArray();
	}

	/**
	 * 获取左侧菜单
	 */
	public function left(){
		$arr = $this
			->where(['status'=>1])
			->select();
		$arrlist = $arr->toArray();
		$list = [];
		foreach($arrlist as $key=>$value){
			$list[$value['classs_id']][$value['id']] = $value;
		}
		return $list;
	}
	
	/**
	 * 获取器
	 */
	public function getStatusAttr($value){
		$config = config('tables.classs.fields.status.options');
		return $config[$value];
	}

	public function getTargetAttr($value){
		$config = config('tables.classs.fields.target.options');
		return $config[$value];
	}

	public function getNavigationAttr($value){
		$config = config('tables.classs.fields.navigation.options');
		return $config[$value];
	}
}

